from ..lib.result_code import *
from .base_services import BaseService
from ..lib.redis_client import RedisHelper


class PrintService(BaseService):
    """
    输出
    """

    def print_hello(self):
        try:
            # 参数非空校验和完整性校验
            if not self.restful_param_check(complete_check=['id'],
                                            null_check=['id']):
                return self.param_check_response_format_json()
            # redis 客户端工具包校验
            conn = RedisHelper().redis_client
            conn.set("hello", "hello world!")
            response = {
                "item": conn.get("hello")
            }
        except Exception as e:
            return CustomErrNo(status_code=SYSTEM_INNER_ERROR, msg=str(e)).to_json()
        return CustomErrNo(payload=response).to_json()
